package com.zhenyi.core.interceptor;

import com.cjw.model.DBMap;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

public class ExceptionInterceptor implements Interceptor {

	@Override
	public void intercept(Invocation inv) {
		try {
			inv.invoke();
		} catch (Exception e) {
			e.printStackTrace();
			DBMap map = new DBMap();
			map.put("status", 500);
			map.put("msg", "系统错误");
			Controller controller = inv.getController();
			controller.setAttr("status", 500);
			controller.setAttr("msg", "系统错误");
			controller.renderJson(map);
		}
	}
}
